#ifndef _BASE
#define _BASE

// INCLUDES --------------------------------------------------------------------
#include "stdbool.h"
#include "string.h"
#include "stdio.h"

#include "math.h"

// DEFINES ---------------------------------------------------------------------
#define DEBUG 1

#ifdef DEBUG

  // ------------------------------------------------------------------
  /* f   -> function name as string
     p   -> pointer to check
     ... -> alternative return value */
  #define GUARD_NULL(f, p, ...) \
  { \
    if (p == NULL) { \
      printf("NULL pointer! [%s->%s:%d]\n", f, __FILE__, __LINE__); \
      return __VA_ARGS__; \
    } \
  }

  /* f   -> function name as string
     k   -> value to check
     ... -> alternative return value */
  #define GUARD_ZERO(f, k, ...) \
  { \
    if (k == 0) { \
      printf("ZERO value! [%s->%s:%d]\n", f, __FILE__, __LINE__); \
      return __VA_ARGS__; \
    } \
  }
  // ------------------------------------------------------------------

#else

  // ------------------------------------------------------------------
  #define GUARD_NULL(f, p, ...) return __VA_ARGS__;
  #define GUARD_ZERO(f, k, ...) return __VA_ARGS__;
  // ------------------------------------------------------------------

#endif // DEBUG

// TYPEDEFS --------------------------------------------------------------------
typedef float              fp;
//typedef double             fp;

typedef int                i32;
typedef unsigned int       ui32;

typedef long               l32;
typedef unsigned long      ul32;

typedef long long          l64;
typedef unsigned long long ul64;

#endif // _BASE
